package com.fi.common.log;


import fivm.cross.platform.steamobj.log.LogMsgStream;
import fivm.cross.platform.steamobj.sys.DeviceConfigs;

public class LogToServlet implements ILogger {
	private static final String LogReportRelativeUrl="/log_report";
	private String envName;			//环境名，比如系统的log，或者zygote的环境或者是app环境里面
	private String identifyName;		//区别于其它的唯一名称
	private static String LogReportUrl;

	public LogToServlet(DeviceConfigs deviceConfigs,String envName){
		this.envName=envName;
		this.identifyName=deviceConfigs.getDeviceSerialNum();
		if(LogReportUrl==null){
			LogReportUrl=deviceConfigs.genUrl(LogReportRelativeUrl);
		}
	}
	public LogToServlet(String serialNum,String envName,String logReportUrl){
		this.identifyName=serialNum;
		this.envName=envName;
		LogReportUrl=logReportUrl;
	}
	
	
	
	private void log(String logMsg){
		LogMsgStream logMsgStream=new LogMsgStream();
		logMsgStream.setLogMsg(logMsg);
		logMsgStream.setDeviceSerialNum(identifyName);
		logMsgStream.setAppName(envName);
		logToServer(logMsgStream);
		
	}
	
    public void  logToServer(LogMsgStream logMsgStream){
    	logMsgStream.toHttp(LogReportUrl);
    }

	public void log(int level, String tag, String msg) {
		log(FiLog.formatLog(tag, level, msg));
	}



    

    
    
    
    
    
}
